<template>
	<view class="page-items">
		<view class="diy-search">
			<view class="inner"  @click="onTargetSearch">
			  <view class="search-input">
				<u-icon size="20" name="search"></u-icon>
				<text>请输入关键词搜索</text>
			  </view>
			</view>
		</view>
		<view class="diy-banner">
			<!-- 图片轮播 -->
			<swiper
			  :autoplay="true"
			  class="swiper-box"
			  :duration="800"
			  :circular="true"
			  :interval="10000"
			  @change="bindChange"
			>
			  <swiper-item v-for="(dataItem, index) in dataList" :key="index">
				<image mode="widthFix" class="slide-image" :src="dataItem.imgUrl"  />
			  </swiper-item>
			</swiper>
			<!-- 指示点 -->
			<view class="indicator-dots">
			  <view
				class="dots-item"
				:class="{ active: imgCurrent == index }"
				v-for="(dataItem, index) in dataList"
				:key="index"
			  ></view>
			</view>
		</view>
		<view class="diy-notice">
		  <u-notice-bar padding="10rpx 24rpx"  :autoplay="true"
		    bg-color="#fffbe8" color="#de8c17" text="当前为演示商城，所有商品均为测试数据，请勿下单（不发货）。"></u-notice-bar>
		</view>
		<view class="diy-navBar">
		  <view class="data-list">
		    <view class="item-nav" v-for="(dataItem, index) in tabList" :key="index">
		      <view class="nav-to" @click="onLink(dataItem.link)">
		        <view class="item-image">
		          <image class="image" mode="widthFix" :src="dataItem.imgUrl"></image>
		        </view>
		        <view class="item-text oneline-hide">{{ dataItem.text }}</view>
		      </view>
		    </view>
		  </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgCurrent: 0 ,// 当前banne所在滑块指针
				dataList: [{
							"imgUrl": "http://static.yoshop.xany6.com/10001/20210314/295000dccb12fe8d7fad7bc4814ec6f4.png",
							"imgName": "banner02.png"
						},
						{
							"imgUrl": "http://static.yoshop.xany6.com/10001/20210314/1938bdd93e11675179b20410dabef3cc.png",
							"imgName": "未标题-1.png"
						}
					],
				tabList:  [
							{
								"imgUrl": "http://static.yoshop.xany6.com/10001/20210315/8749305b19496b7b5b0b098837357a80.png",
								"imgName": "icon-2.jpg",
								"link": {
									"id": "995bf1c",
									"title": "商品列表页",
									"type": "PAGE",
									"param": {
										"path": "pages/goods/list",
										"query": {
											"categoryId": "10085",
											"search": ""
										}
									},
									"form": [
										{
											"key": "query.categoryId",
											"lable": "分类ID",
											"tips": "商品管理 -> 商品分类",
											"value": "10085"
										},
										{
											"key": "query.search",
											"lable": "关键词",
											"tips": "搜索的关键词，用于匹配商品名称",
											"value": ""
										}
									]
								},
								"text": "居家生活"
							},
							{
								"imgUrl": "http://static.yoshop.xany6.com/10001/20210315/003ebfff145bd74289b8ad5510b6a01e.png",
								"imgName": "icon-3.jpg",
								"link": {
									"id": "995bf1c",
									"title": "商品列表页",
									"type": "PAGE",
									"param": {
										"path": "pages/goods/list",
										"query": {
											"categoryId": "10001",
											"search": ""
										}
									},
									"form": [
										{
											"key": "query.categoryId",
											"lable": "分类ID",
											"tips": "商品管理 -> 商品分类",
											"value": "10001"
										},
										{
											"key": "query.search",
											"lable": "关键词",
											"tips": "搜索的关键词，用于匹配商品名称",
											"value": ""
										}
									]
								},
								"text": "手机数码"
							},
							{
								"imgUrl": "http://static.yoshop.xany6.com/10001/20210315/49251b6557e20faee7c67d9ee331a98b.png",
								"imgName": "icon-1.png",
								"link": {
									"id": "56sswhq",
									"title": "领券中心",
									"type": "PAGE",
									"param": {
										"path": "pages/coupon/index"
									}
								},
								"text": "领券中心"
							},
							{
								"imgUrl": "http://static.yoshop.xany6.com/10001/20210315/7a5fde286eb3c79e80be0b3f82f2079b.png",
								"imgName": "icon-4.jpg",
								"link": {
									"id": "995bf1c",
									"title": "商品列表页",
									"type": "PAGE",
									"param": {
										"path": "pages/goods/list",
										"query": {
											"categoryId": "10088",
											"search": ""
										}
									},
									"form": [
										{
											"key": "query.categoryId",
											"lable": "分类ID",
											"tips": "商品管理 -> 商品分类",
											"value": "10088"
										},
										{
											"key": "query.search",
											"lable": "关键词",
											"tips": "搜索的关键词，用于匹配商品名称",
											"value": ""
										}
									]
								},
								"text": "运动户外"
							}
						]
			}
		},
		methods: {
			bindChange(e) {
			  this.imgCurrent = e.detail.current;
			},
			onLink (row) {
				this.$navTo(row.param.path, row.param.query)
			}
		}
	}
</script>

<style lang="scss" scoped>
  .diy-search {
    background: #f1f1f2;
    padding: 20rpx 20rpx;
    font-size: 26rpx;
	  .inner {
		height: 60rpx;
		background: #fff;
		overflow: hidden;
	    border-radius: 60rpx;
	  }

	  .search-input {
		height: 60rpx;
		color: #999;
		padding: 0 20rpx;
		display: flex;
		align-items: center;
		border-radius: 50%;

		.search-icon {
		  margin-right: 8rpx;
		}
	  }
    }
	.diy-banner {
	  position: relative;
	  // swiper组件
	  .swiper-box {
	    .slide-image {
	      width: 100%;
	      height: 100rpx;
	      margin: 0 auto;
	      display: block;
	    }
	  }
	
	  /* 指示点 */
	  .indicator-dots {
	    width: 100%;
	    height: 28rpx;
	    padding: 0 20rpx;
	    position: absolute;
	    left: 0;
	    right: 0;
	    bottom: 10px;
	    opacity: 0.8;
	    display: flex;
	    justify-content: center;
	
	    .dots-item {
	      width: 16rpx;
	      height: 16rpx;
	      margin-right: 8rpx;
	      background-color: #fff;
		  border-radius: 20rpx;
	      &:last-child {
	        margin-right: 0;
	      }
	      &.active {
	        background-color: #313131 !important;
	      }
	    }
	  }
	}
	.diy-notice{
		font-size: 20rem;
	}
	.diy-navBar {
		.data-list::after {
		  clear: both;
		  content: " ";
		  display: table;
		}
		.item-nav {
		  float: left;
		  margin: 10px 0;
		  text-align: center;
		  width: 25%;
		  .item-text {
		    font-size: 26rpx;
		  }
		
		  .item-image {
		    margin-bottom: 4px;
		    font-size: 0;
		  }
		
		  .item-image .image {
		    width: 88rpx;
		    height: 88rpx;
		  }
		
		}
	}
	
	
</style>

